package com.foreknow.demo11;

public class StringDemo2 {
    public static void main(String[] args) {
        String s1 = "haha";
        String s2 = "haha";
        String s3 = new String("haha");
        String s4 = new String("haha");
        String s5 = "ha" + "ha";
        String s6 = new String("ha") + "ha";

        System.out.println(s1==s2); //true
        System.out.println(s1.equals(s2)); //true
        System.out.println(s1==s3); //false 内存地址不同
        System.out.println(s1==s5); //true
        System.out.println(s3==s4); //false 内存地址不同
        System.out.println(s3==s5); //false 内存地址不同
        System.out.println(s5==s6); //false 内存地址不同
        System.out.println(s3==s6); //false 内存地址不同
//        System.out.println(s2);
//        System.out.println(s3);
//        System.out.println(s4);
//        System.out.println(s5);
//        System.out.println(s6);
    }
}
